import request from "@/utils/request";
import requestMock from "@/utils/requestMock";
//统一管理项目全部接口
//获取商品分类的数据接口
//切记API统一封装的时候,需要用到关键字return,返回一个promise对象
//如果没有书写return,组件获取到的是undefined.xxxxx出现报错现象
export const reqCategory = () => {
  return request({ url: "/product/getBaseCategoryList", method: "get" });
};

export const reqBanner = () => requestMock({ url: "/banner" }); //默认get
export const reqFloor = () => requestMock({ url: "/floor" });
export const reqSearchList = (data) =>
  request({ url: "/list", method: "post", data });

export const reqGoodsDetail = (skuId) =>
  request({ url: `/item/${skuId}`, method: "get" });
export const reqAddOrUpdateCart = (skuId, skuNum) =>
  request({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: "post" });

//获取用户购物车的数据
export const reqShopCart = () =>
  request({ url: `/cart/cartList`, method: "get" });
export const reqUpdateChecked = (skuId, isChecked) =>
  request({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: "get" });
export const reqRemoveGood = (skuId) =>
  request({ url: `/cart/deleteCart/${skuId}`, method: "delete" });
export const reqCode = (phone) =>
  request({ url: `/user/passport/sendCode/${phone}`, method: "get" });
export const reqUserRegister = (data) =>
  request({ url: `/user/passport/register`, method: "post", data });
export const reqUserLogin = (data) =>
  request({ url: `/user/passport/login`, method: "post", data });
export const reqUserInfo = () =>
  request({ url: "/user/passport/auth/getUserInfo" });
export const reqUserLogout = () => request({ url: `/user/passport/logout` });
export const reqTrade = () =>
  request({ url: `/user/userAddress/auth/findUserAddressList` });
export const reqGoods = () => request({ url: `/order/auth/trade` });
export const reqSubmitOrder = (tradeNo, data) =>
  request({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: "post",
    data,
  });
export const reqPayInfo = (orderId) =>
  request({ url: `/payment/weixin/createNative/${orderId}`, method: "get" });
export const reqPayState = (orderId) =>
  request({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: "get" });
export const reqMyOrder = (page, limit) =>
  request({ url: `/order/auth/${page}/${limit}`, method: "get" });
